﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Xml.Linq;
using HelixToolkit.Wpf;
using UniversalEditor.Base;
using UniversalEditor.Base.FileSystem;
using UniversalEditor._3d.Viewport;

namespace UniversalEditor._3d
{
    public class DirectxEditor : EditorBase
    {
		private readonly Lazy<ViewportView> _media;

		public DirectxEditor(IEditorOwner owner, FileWrapper file)
			: base(owner, file)
	    {
			_media = new Lazy<ViewportView>(CreateViewportView);
	    }

		private ViewportView CreateViewportView()
		{
			ModelImporter importer = new ModelImporter();
            
			ViewportModel model = new ViewportModel();
			model.Model = importer.Load(_file.FilePath);

			ViewportView item = new ViewportView();
			item.DataContext = new ViewportViewModel(model);

			return item;
		}

		public override FrameworkElement EditorControl
		{
			get { return _media.Value; }
		}
    }
}
